<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>
    <xsl:template match="BBB">
        <html>
            <body>
               <p><xsl:value-of select="@id"/></p>
               <xsl:for-each select="parent::*">
                    <p><xsl:text> PARENT ID: </xsl:text> <xsl:value-of select="@id"/></p>
               </xsl:for-each>
               </body>
        </html>
    </xsl:template>

</xsl:stylesheet>
